package controllers;

import java.io.File;

import com.google.gson.JsonObject;

import play.mvc.Controller;
import util.FileUtil;

public class UploadController extends Controller {

	public static void upload(File imgFile) {

		String picPath = FileUtil.uploadFile(imgFile);
		JsonObject obj = new JsonObject();
		obj.addProperty("error", 0);
		obj.addProperty("url", FileUtil.PicPath+picPath);
		
		renderJSON(obj.toString());
		
//		json.append("<html>");
//		json.append("<head>");
//		json.append("<title>Insert Image</title>");
//		json.append("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">");
//		json.append("</head>");
//		json.append("<body>");
//		json.append("<script type=\"text/javascript\">parent.KE.plugin[\"image\"].insert(\"" + id + "\",\""
//				+ file_lastName + "\",\"" + imgTitle + "\",\"" + imgWidth + "\",\"" + imgHeight + "\",\"" + imgBorder
//				+ "\" );</script>");
//		json.append("</body>");
//		json.append("</html>");

		
	}

}
